package com.gusti.turnos.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import com.gusti.turnos.persistence.model.AbstractModelObject;

/**
 * 
 * @author gusti
 *
 */
@Entity
@Table( uniqueConstraints={ @UniqueConstraint(columnNames={"email"}), @UniqueConstraint(columnNames={"uuid"}) } )
public class User extends AbstractModelObject {

	private static final long serialVersionUID = -4274814355554398229L;

	//PROPERTIES
	private String name;
	private String surname;
	private String email; //unique identifier
	private String password;
	private String uuid; //unique identifier
	private UserRol userRol;
	private boolean resetPassword;

	//MODIFIERS
	@Basic(optional=false)
	@Column(nullable=false)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@Basic(optional=false)
	@Column(nullable=false)
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}

	@Basic(optional=false)
	@Column(nullable=false)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

	@Basic(optional=false)
	@Column(nullable=false)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	@Basic(optional=false)
	@Column(nullable=false)
	public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	@Enumerated(EnumType.STRING )
	@Basic(optional=false)
	@Column(nullable=false)
	public UserRol getUserRol() {
		return userRol;
	}
	public void setUserRol(UserRol userRol) {
		this.userRol = userRol;
	}

	@Basic(optional=false)
	@Column(nullable=false)
	public boolean isResetPassword() {
		return resetPassword;
	}
	public void setResetPassword(boolean resetPassword) {
		this.resetPassword = resetPassword;
	}

	//OTHERS
	@Transient
	public boolean isAdmin() {
		return this.userRol == UserRol.ADMIN;
	}
}
